<?php
/**
 * Edit / add a bookmark
 *
 * @package Bookmarks
 */
$title = elgg_extract('title', $vars, '');
$score = elgg_extract('score', $vars, '');
$year = date('Y');
$month = date('m');
$day = date('d');
$course_id = '0';
$score_type = 1;
$holes_played = 18;
if($score) {
	$year = date('Y', strtotime($score->input_date));
	$month = date('m', strtotime($score->input_date));
	$day = date('d', strtotime($score->input_date));
	$course_id = $score->golf_course_id;
	$score_type = $score->score_type;
	$holes_played = $score->holes_played;
}

$courses = elgg_extract('courses', $vars, '');
$courses__param = array('0' => '---choose course---');
foreach ($courses as $course) {
	$courses__param[$course->golf_course_id] = $course->course_name;
}
?>

<div class="elgg-add-score">
<?php
		echo '<div class="elgg-foot" style="margin-top: 5px;">';
		echo elgg_view('input/button', array(
				'value' => elgg_echo('golfscore:done'),
				'onclick' => 'onSaveScoreForm(\''.$score->golf_score_id.'\',\''.get_input('hole').'\');',
				'class' => 'btnDone'	
			));
		echo '</div>';
	?>
<div id="__enter_course">
	<input type="hidden" name="golf_score_id" id="__golf_score_id" value="<?php echo $score->golf_score_id;?>">
	<input type="hidden" id="__hole" value="<?php echo get_input('hole');?>"/>
	<input type="hidden" id="__tee" value="<?php echo get_input('tee');?>"/>

	<div style="display: none;" class="enter_score_type">
		
		<?php echo elgg_view("input/radio", array(
			'name' => 'score_type',
			'value' => $score_type,
			'id' => '__score_type',
			'onchange' => 'onSelectCourse();',
			'class' => 'elgg-golfscore-radio-scoretype',
			'options' => array(
				elgg_echo('golfscore:add:scoretype:detail') => '1',
				elgg_echo('golfscore:add:scoretype:total') => '2',
			),
		)); ?>
		<div style="display: none;" id="__holes_played" class="elgg-golfscore-div-holesplayed" style="display: <?php if($score_type == 2) echo ''; else echo none;?>;">
			<?php echo elgg_view("input/radio", array(
				'name' => 'holes_played',
				'value' => $holes_played,
				'class' => 'elgg-golfscore-radio-holesplayed',
				'options' => array(
					'18' => '18',
					elgg_echo('golfscore:add:holesplayed:other') => '0',
				),
			)); ?>
		</div>
	</div>
	<div style="display: none;" class="enter_score_date">
		
		<?php echo elgg_view('input/dropdown', array(
			'class' => 'elgg-golfscore-select-date-month', 
			'name' => 'month',
			'value' => $month,
			'options_values' => array(
				'1' => elgg_echo('date:month:01', array('')),
				'2' => elgg_echo('date:month:02', array('')),
				'3' => elgg_echo('date:month:03', array('')),
				'4' => elgg_echo('date:month:04', array('')),
				'5' => elgg_echo('date:month:05', array('')),
				'6' => elgg_echo('date:month:06', array('')),
				'7' => elgg_echo('date:month:07', array('')),
				'8' => elgg_echo('date:month:08', array('')),
				'9' => elgg_echo('date:month:09', array('')),
				'10' => elgg_echo('date:month:10', array('')),
				'11' => elgg_echo('date:month:11', array('')),
				'12' => elgg_echo('date:month:12', array(''))
			),
		)); ?>
		<?php echo elgg_view('input/dropdown', array(
			'class' => 'elgg-golfscore-select-date-day', 
			'name' => 'day', 
			'value' => $day,
			'options_values' => array(
				'1' => '1','2' => '2','3' => '3','4' => '4',
				'5' => '5','6' => '6','7' => '7','8' => '8',
				'9' => '9','10' => '10','11' => '11','12' => '12',
				'13' => '13','14' => '14','15' => '15','16' => '16',
				'17' => '17','18' => '18','19' => '19','20' => '20',
				'21' => '21','22' => '22','23' => '23','24' => '24',
				'25' => '25','26' => '26','27' => '27','28' => '28',
				'29' => '29','30' => '30','31' => '31'
			)
		)); ?>
		<?php echo elgg_view('input/dropdown', array(
			'class' => 'elgg-golfscore-select-date-year', 
			'name' => 'year', 
			'value' => $year,
			'options_values' => array(
				'' . ($year - 10) => '' . ($year - 10),
				'' . ($year - 9) => '' . ($year - 9),
				'' . ($year - 8) => '' . ($year - 8),
				'' . ($year - 7) => '' . ($year - 7),
				'' . ($year - 6) => '' . ($year - 6),
				'' . ($year - 5) => '' . ($year - 5),
				'' . ($year - 4) => '' . ($year - 4),
				'' . ($year - 3) => '' . ($year - 3),
				'' . ($year - 2) => '' . ($year - 2),
				'' . ($year - 1) => '' . ($year - 1),
				'' . ($year) => '' . ($year),
				'' . ($year + 1) => '' . ($year + 1),
				'' . ($year + 2) => '' . ($year + 2),
				'' . ($year + 3) => '' . ($year + 3),
				'' . ($year + 4) => '' . ($year + 4),
				'' . ($year + 5) => '' . ($year + 5),
				'' . ($year + 6) => '' . ($year + 6),
				'' . ($year + 7) => '' . ($year + 7),
				'' . ($year + 8) => '' . ($year + 8),
				'' . ($year + 9) => '' . ($year + 9),
				'' . ($year + 10) => '' . ($year + 10),
			)
		)); ?>
	</div>
	<div style="display: none;" class="enter_score_select_course">
		
		<?php echo elgg_view('input/dropdown', array(
			'class' => 'elgg-golfscore-select-course', 
			'name' => 'course', 
			'id' => '__courses',
			'onchange' => 'onSelectCourse();',
			'value' => $course_id,
			'options_values' => $courses__param,
		)); ?>
	</div>
	<div id="__course_detail_temp" style="display: <?php if($score) echo 'none'; else echo 'block';?>;">
		<div class="course_detail">
		<div class="course_l">
		<div id="__tee_color" class="elgg-golfscore-icon-tee-white">&nbsp;</div>
		
		<?php echo elgg_view('input/dropdown', array(
			'class' => 'elgg-golfscore-select-tee', 
			'value' => 'white',
			'id' => '__tee_temp',
			'options_values' => array(
				'gold' => 'Gold',
				'blue' => 'Blue',
				'white' => 'White',
				'red' => 'Red',
			),
		)); ?>
		</div>
		
		<div class="course_r">
		<?php echo elgg_view('input/text', array(
			'class' => 'elgg-golfscore-text-rating',
			'placeholder' => 'Rating', 
			'value' => '',
		)); ?>
		
		<?php echo elgg_view('input/text', array(
			'class' => 'elgg-golfscore-text-slope', 
				'placeholder' => 'Slope',
			'value' => '',
				
		)); ?>
		</div>
		</div>
		<div class="enter_score_detail">
			<div id="__hole">
				
				<div class="labelHoleBox"><?php echo elgg_echo('golfscore:add:hole'); ?></div>
				<div class="editHoleBox">1</div>
				<div class="editHoleBox">2</div>
				<div class="editHoleBox">3</div>
				<div class="editHoleBox">4</div>
				<div class="editHoleBox">5</div>
				<div class="editHoleBox">6</div>
				<div class="editHoleBox">7</div>
				<div class="editHoleBox">8</div>
				<div class="editHoleBox">9</div>
				<div class="totalHoleBox"><?php echo elgg_echo('golfscore:add:out'); ?></div>
				<div class="editHoleBox">10</div>
				<div class="editHoleBox">11</div>
				<div class="editHoleBox">12</div>
				<div class="editHoleBox">13</div>
				<div class="editHoleBox">14</div>
				<div class="editHoleBox">15</div>
				<div class="editHoleBox">16</div>
				<div class="editHoleBox">17</div>
				<div class="editHoleBox">18</div>
				<div class="totalHoleBox"><?php echo elgg_echo('golfscore:add:in'); ?></div>
				<div class="totalHoleBox"><?php echo elgg_echo('golfscore:add:total'); ?></div>
				
				
			</div>
			<div id="__distance">
				<div class="labelHoleBox"><?php echo elgg_echo('golfscore:add:distance'); ?></div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="totalHoleBox">0</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="totalHoleBox">0</div>
				<div id="" class="totalHoleBox">0</div>
				
			</div>
			<div id="__par">
				<div class="labelHoleBox"><?php echo elgg_echo('golfscore:add:par'); ?></div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="totalHoleBox">0</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="editHoleBox">&nbsp;</div>
				<div id="" class="totalHoleBox">0</div>
				<div id="" class="totalHoleBox">0</div>
				
			</div>
			<div id="__score">
				<div class="labelHoleBox"><?php echo elgg_echo('golfscore:add:score'); ?></div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="totalHoleBox">0</div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="editHoleBox"> </div>
				<div id="" class="totalHoleBox">0</div>
				<div id="" class="totalHoleBox">0</div>
				
			</div>
		</div>
	</div>
	<div id="__course_detail" style="margin-top: 5px; display: <?php if($score) echo 'block'; else echo 'none';?>;">
		<?php echo elgg_view('golfscore/fetch_course_edit', array(
				'golf_course_id' => $score->golf_course_id,
				'tee' => $score->tee,
				'score_type' => $score->score_type,
				'score' => $score
				))?>
	</div>
</div>
</div>